/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.fundacionincap.VO;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author langeblanc
 */
@Entity
@Table(name = "convenio", catalog = "AsignacionCarga", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Convenio.findAll", query = "SELECT c FROM Convenio c"),
    @NamedQuery(name = "Convenio.findByIdConvenio", query = "SELECT c FROM Convenio c WHERE c.idConvenio = :idConvenio"),
    @NamedQuery(name = "Convenio.findByNombre", query = "SELECT c FROM Convenio c WHERE c.nombre = :nombre")})
public class Convenio implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 5)
    @Column(name = "idConvenio")
    private String idConvenio;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "nombre")
    private String nombre;
    @JoinTable(name = "convenio_has_tutor", joinColumns = {
        @JoinColumn(name = "Convenio_idConvenio", referencedColumnName = "idConvenio")}, inverseJoinColumns = {
        @JoinColumn(name = "Tutor_numeroDocumento", referencedColumnName = "numeroDocumento")})
    @ManyToMany
    private Collection<Tutor> tutorCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "convenio")
    private Collection<Programaacademico> programaacademicoCollection;

    public Convenio() {
    }

    public Convenio(String idConvenio) {
        this.idConvenio = idConvenio;
    }

    public Convenio(String idConvenio, String nombre) {
        this.idConvenio = idConvenio;
        this.nombre = nombre;
    }

    public String getIdConvenio() {
        return idConvenio;
    }

    public void setIdConvenio(String idConvenio) {
        this.idConvenio = idConvenio;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    @XmlTransient
    public Collection<Tutor> getTutorCollection() {
        return tutorCollection;
    }

    public void setTutorCollection(Collection<Tutor> tutorCollection) {
        this.tutorCollection = tutorCollection;
    }

    @XmlTransient
    public Collection<Programaacademico> getProgramaacademicoCollection() {
        return programaacademicoCollection;
    }

    public void setProgramaacademicoCollection(Collection<Programaacademico> programaacademicoCollection) {
        this.programaacademicoCollection = programaacademicoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idConvenio != null ? idConvenio.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Convenio)) {
            return false;
        }
        Convenio other = (Convenio) object;
        if ((this.idConvenio == null && other.idConvenio != null) || (this.idConvenio != null && !this.idConvenio.equals(other.idConvenio))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.edu.fundacionincap.VO.Convenio[ idConvenio=" + idConvenio + " ]";
    }
    
}
